package com.cha.chaApp.vaccination.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.cha.chaApp.vaccination.param.VaccinationParam;
import com.cha.chaApp.vaccination.service.VaccinationService;
import com.cha.chaApp.vaccination.vo.VaccinationVO;
import com.cha.chaCommon.core.common.PageParam;
import com.cha.chaCommon.core.common.R;
import com.cha.chaCommon.core.entity.hgq.Vaccination;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
@Api(tags = "疫苗状态表")
@RestController
@RequestMapping("/vaccination")
public class VaccinationController {
    @Resource
    private VaccinationService vaccinationService;
    @ApiOperation(
            value ="查询所有打疫苗的状态",
            notes = "1")
    @GetMapping("/list")
    public R list(PageParam param,Integer babyId){
        IPage<VaccinationVO> vaccinationVOIPage = vaccinationService.selectOrderPage(param, babyId);
        return R.ok(vaccinationVOIPage);
    }
    @ApiOperation(
            value ="添加打疫苗的状态",
            notes = "创建时间和修改时间后端自动添加")
    @PostMapping("/add")
    public R add(@RequestBody VaccinationParam param){
        vaccinationService.addVaccination(param);
        return R.ok();
    }
    @ApiOperation(
            value ="修改打疫苗的状态",
            notes = "创建时间和修改时间后端自动添加")
    @PostMapping("/update")
    public R update(@RequestBody Vaccination vaccination){
        vaccinationService.updateVaccination(vaccination);
        return R.ok();
    }
}
